Skip to content

Implement AuthenticationTagMismatchException exception - #75160

Merged
vcsjones merged 9 commits into
dotnet:mainfrom
vcsjones:auth-tag-mismatch
Sep 30, 2022
Merged

Implement AuthenticationTagMismatchException exception#75160
vcsjones merged 9 commits into
dotnet:mainfrom
vcsjones:auth-tag-mismatch

Conversation

@vcsjones

@vcsjones vcsjones commented Sep 6, 2022

Copy link
Copy Markdown
Member

This introduces a new AuthenticationTagMismatchException for AEAD ciphers to throw during decryption when the authentication tag produces a mismatch.

Previously for Android, we were assuming any failure meant "auth tag mismatch". This changes the native shim to properly catch and handle the Android AEADBadTagException.

Closes #67082

@ghost

ghost commented Sep 6, 2022

Copy link
Copy Markdown

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost ghost assigned vcsjones Sep 6, 2022
@ghost

ghost commented Sep 6, 2022

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/area-system-security, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

This introduces a new AuthenticationTagMismatchException for AEAD ciphers to throw during decryption when the authentication tag produces a mismatch.

Previously for Android, we were assuming anything mean "auth tag mismatch". This changes the native shim to properly catch and handle the Android AEADBadTagException.

Author: vcsjones
Assignees: -
Labels:

area-System.Security, new-api-needs-documentation

Milestone: -

@vcsjones

vcsjones commented Sep 6, 2022

Copy link
Copy Markdown
Member Author

Draft to get a run through CI. Android is very unhappy in my local dev.

Comment thread src/native/libs/System.Security.Cryptography.Native.Android/pal_cipher.c Outdated
@vcsjones vcsjones changed the title Auth tag mismatch Implement AuthenticationTagMismatchException exception Sep 6, 2022
@vcsjones

vcsjones commented Sep 6, 2022

Copy link
Copy Markdown
Member Author

/azp run runtime-extra-platforms

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones

vcsjones commented Sep 7, 2022

Copy link
Copy Markdown
Member Author

/azp run runtime-extra-platforms

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones

vcsjones commented Sep 7, 2022

Copy link
Copy Markdown
Member Author

The x86 and x64 Android legs passed. The ARM64 seemed to crash. I also cannot get the ARM64 tests to run locally, but that's true even on main, so I don't think I introduced any incorrect behavior.

Marking as ready for review, then.

@vcsjones
vcsjones marked this pull request as ready for review September 7, 2022 14:53
@bartonjs

Copy link
Copy Markdown
Member

@jkoritzinsky can you weigh in on the JNI parts?

@vcsjones

Copy link
Copy Markdown
Member Author

/azp run runtime-extra-platforms

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones

Copy link
Copy Markdown
Member Author

/azp run runtime-extra-platforms

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones

Copy link
Copy Markdown
Member Author

@bartonjs @jkoritzinsky I am having a hard time parsing the results of the Android test runs. I don't see anything in the test results that look like a failure as a result from this change. Can either of you help me confirm that and this is okay to merge?

@filipnavara

filipnavara commented Sep 29, 2022

Copy link
Copy Markdown
Member

It is related:

09-29 06:08:20.250  3012  3012 I DOTNET  : JNI_OnLoad: JNI_OnLoad in pal_jni.c
09-29 06:08:20.251  3012  3012 F DOTNET  : GetClassGRef: class javax/crypto/spec/AEADBadTagException was not found
--------- beginning of crash
09-29 06:08:20.251  3012  3012 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 3012 (rimitives.Tests), pid 3012 (rimitives.Tests)

Taken from one of the MonoRunner logs here

Comment thread src/native/libs/System.Security.Cryptography.Native.Android/pal_jni.c Outdated
…l_jni.c

Co-authored-by: Filip Navara <filip.navara@gmail.com>
@vcsjones

Copy link
Copy Markdown
Member Author

/azp run runtime-extra-platforms

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones

Copy link
Copy Markdown
Member Author

/azp run runtime-extra-platforms

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones

Copy link
Copy Markdown
Member Author

/azp run runtime-extra-platforms

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones
vcsjones merged commit 60b40c3 into dotnet:main Sep 30, 2022
@vcsjones
vcsjones deleted the auth-tag-mismatch branch September 30, 2022 12:57
@ghost ghost locked as resolved and limited conversation to collaborators Oct 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: Authenticated ciphers should distigush between mismatched tag and failure

4 participants